<html>
<head><meta charset="utf-8"><title>ManuallyDrop::&lt;Box&lt;T&gt;&gt;::take UB? · t-lang/wg-unsafe-code-guidelines · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/index.html">t-lang/wg-unsafe-code-guidelines</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/ManuallyDrop.3A.3A.3CBox.3CT.3E.3E.3A.3Atake.20UB.3F.html">ManuallyDrop::&lt;Box&lt;T&gt;&gt;::take UB?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="200732353"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/ManuallyDrop%3A%3A%3CBox%3CT%3E%3E%3A%3Atake%20UB%3F/near/200732353" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/ManuallyDrop.3A.3A.3CBox.3CT.3E.3E.3A.3Atake.20UB.3F.html#200732353">(Jun 12 2020 at 22:36)</a>:</h4>
<p>I have a <code>ManuallyDrop&lt;Box&lt;T&gt;&gt;</code>. This is working out great for me, except I need it as a <code>Box&lt;T&gt;</code> when it comes to actually <code>drop</code> it. <code>drop(&amp;mut self)</code> makes this slightly annoying. What I'm doing is using <code>ManuallyDrop::take</code>, which seems designed for this exact case... but I vaguely remember rules about Box's inner <code>Unique</code> having weird LLVM requirements, and if i use <code>ManuallyDrop::take</code>, I will have both a <code>Box&lt;T&gt;</code> and a <code>ManuallyDrop&lt;Box&lt;T&gt;&gt;</code> that refer to the same location and are both "active" (for lack of  a better term) even though the latter I never intend to touch again. Just wanted to check, is this UB, or am I good?</p>



<a name="200758764"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/ManuallyDrop%3A%3A%3CBox%3CT%3E%3E%3A%3Atake%20UB%3F/near/200758764" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/ManuallyDrop.3A.3A.3CBox.3CT.3E.3E.3A.3Atake.20UB.3F.html#200758764">(Jun 13 2020 at 09:59)</a>:</h4>
<p>I'm afraid I have no idea what the actual question here is :)</p>



<a name="200758803"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/ManuallyDrop%3A%3A%3CBox%3CT%3E%3E%3A%3Atake%20UB%3F/near/200758803" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/ManuallyDrop.3A.3A.3CBox.3CT.3E.3E.3A.3Atake.20UB.3F.html#200758803">(Jun 13 2020 at 10:00)</a>:</h4>
<p><span class="user-mention" data-user-id="209168">@Thom Chiovoloni</span> if you have some concrete code in your mind, could you show a self-contained piece of code (ideally on the playground) that you are worried about?</p>



<a name="200758825"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/ManuallyDrop%3A%3A%3CBox%3CT%3E%3E%3A%3Atake%20UB%3F/near/200758825" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/ManuallyDrop.3A.3A.3CBox.3CT.3E.3E.3A.3Atake.20UB.3F.html#200758825">(Jun 13 2020 at 10:00)</a>:</h4>
<p>your rough sketch is unfortunately too abstract for me to figure out what, concretely, it is you want to do</p>



<a name="200759136"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/ManuallyDrop%3A%3A%3CBox%3CT%3E%3E%3A%3Atake%20UB%3F/near/200759136" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> isHavvy <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/ManuallyDrop.3A.3A.3CBox.3CT.3E.3E.3A.3Atake.20UB.3F.html#200759136">(Jun 13 2020 at 10:09)</a>:</h4>
<p>Can you call ManuallyDrop::IntoInner instead?</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>